package damngoodcoffee.smart.interpreters;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.xml.sax.helpers.AttributesImpl;

import atunit.AtUnit;
import atunit.Container;
import atunit.MockFramework;
import atunit.Stub;
import atunit.Unit;

import com.google.inject.Inject;

import damngoodcoffee.smart.Parser;
import damngoodcoffee.smart.tags.StartTag;

@RunWith(AtUnit.class)
@Container(Container.Option.GUICE)
@MockFramework(MockFramework.Option.JMOCK)
public class AnchorInterpreterTest {
    @Unit
    @Inject
    AnchorInterpreter interpreter;

    @Inject
    @Stub
    Parser parser;

    @Test
    public void itShouldHandleAnchors() {
	AttributesImpl att = new AttributesImpl();
	att.addAttribute("", "rel", "", "", "");
	StartTag t = new StartTag("a", "", "", att);
	assertTrue(interpreter.canInterpret(t));
    }

    @Test
    public void itShouldIgnoreNoFollowLinks() {
	AttributesImpl att = new AttributesImpl();
	att.addAttribute("", "rel", "", "", "nofollow");
	StartTag t = new StartTag("a", "", "", att);
	assertFalse(interpreter.canInterpret(t));
    }
}
